<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        var arr = ['a', 'a', 'a', 'b', 'b', 'c', 'c', 'c', 'c', 'd', 'd', 'd', 'd']

        function zhuanObj(arr) {
            var obj = {}
            for (var i = 0; i < arr.length; i++) {
                if (obj[arr[i]] == undefined) {
                    obj[arr[i]] = 1
                } else if (obj[arr[i]] !== undefined) {
                    obj[arr[i]] += 1
                }
            }

            console.log(obj);
        }

        zhuanObj(arr);
    </script>
</head>

<body>

</body>

</html>